import request from '@/utils/request'

// 查询调拨列表
export function listTransfer(query) {
  return request({
    url: '/wms/transfer/list',
    method: 'get',
    params: query
  })
}

// 查询调拨详细
export function getTransfer(transferId) {
  return request({
    url: '/wms/transfer/' + transferId,
    method: 'get'
  })
}

// 新增调拨
export function addTransfer(data) {
  return request({
    url: '/wms/transfer',
    method: 'post',
    data: data
  })
}

// 修改调拨
export function updateTransfer(data) {
  return request({
    url: '/wms/transfer',
    method: 'put',
    data: data
  })
}

// 删除调拨
export function deleteTransfer(transferId) {
  return request({
    url: '/wms/transfer/' + transferId,
    method: 'delete'
  })
}

// 审批调拨
export function approveTransfer(transferId, comment) {
  return request({
    url: '/wms/transfer/approve',
    method: 'post',
    data: {
      transferId,
      comment
    }
  })
}

// 执行调拨
export function executeTransfer(transferId) {
  return request({
    url: '/wms/transfer/execute/' + transferId,
    method: 'post'
  })
}

// 取消调拨
export function cancelTransfer(transferId, reason) {
  return request({
    url: '/wms/transfer/cancel',
    method: 'post',
    data: {
      transferId,
      reason
    }
  })
}

// 导出调拨
export function exportTransfer(query) {
  return request({
    url: '/wms/transfer/export',
    method: 'get',
    params: query
  })
}

// 获取仓库列表
export function listWarehouse() {
  return request({
    url: '/wms/warehouse/listAll',
    method: 'get'
  })
}

// 根据物料编码获取物料信息
export function getMaterialByCode(warehouseId, materialCode) {
  return request({
    url: '/wms/material/getByCode',
    method: 'get',
    params: {
      warehouseId,
      materialCode
    }
  })
}